<?php
namespace Admin\Controller;
use Think\Controller;
class EditCharityController extends Controller {
    public function index() {
        $this->display('./Public/admin/edit_charity.html');
    }

    public function save() {
        if (!empty($_POST))
        {
            $map['title'] = $_POST['title'];
            $map['location'] = $_POST['location'];
            $map['amount'] = doubleval($_POST['amount']);
            $map['text'] = $_POST['text'];
            $map['text2'] = $_POST['text2'];
            $map['pid'] = intval($_POST['pid']);
            $map['pid2'] = intval($_POST['pid2']);

            $c = D('Charity');
            if ($c->create($map)) {
                if ($c->add()) {
                    $this->success('新增成功', U('Admin/Index/charity'), 3);
                } else $this->error('新增失败');
            } else $this->error('create失败');
        }
    }
}